/**
 *
 */
package com.isoftstone.framework.domain;

import org.springframework.stereotype.Repository;

/**
 * 消息返回类
 *
 * @author Administrator
 */
@Repository
public class Tidings<T> {
    private boolean status = true;
    private String msg = "操作成功";
    private T t;
    private Page page;

    private int totalResult; //总记录数

    public int getTotalResult() {
        return totalResult;
    }

    public void setTotalResult(int totalResult) {
        this.totalResult = totalResult;
    }

    public Tidings() {

    }

    public Tidings(boolean status, String msg, int totalResult, T t) {
        this.status = status;
        this.msg = msg;
        this.t = t;
        this.totalResult = totalResult;
    }

    public boolean isStatus() {
        return status;
    }

    public void setStatus(boolean status) {
        this.status = status;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getT() {
        return t;
    }

    public Tidings setT(T t) {
        this.t = t;
        return this;
    }

    public Page getPage() {
        return page;
    }

    public void setPage(Page page) {
        this.page = page;
    }


    /**
     * 返回错误消息
     *
     * @param msg 返回内容
     * @return 警告消息
     */
    public static Tidings error(String msg,Object t) {
        return new Tidings(false, msg, 0, t);
    }

    public static Tidings error(String msg) {
        return new Tidings(false, msg, 0, null);
    }
    public static Tidings success() {
        return success(true, "操作成功", 0, null);
    }

    public static Tidings success(Object t) {
        return success(true, "操作成功", 0, t);
    }

    public static Tidings success(int totalResult, Object t) {
        return success(true, "操作成功", totalResult, t);
    }

    public static Tidings success(String msg, int totalResult, Object t) {
        return success(true, msg, totalResult, t);
    }

    public static Tidings success(boolean status, String msg, int totalResult, Object t) {
        return new Tidings(status, msg, totalResult, t);
    }
}
